
function toRad(degrees){
return degrees * Math.PI / 180;
}
export function getDistance(lat1, lon1, lat2, lon2) {
	const R = 6371; // 地球平均半径（公里）
	const dLat = this.toRad(lat2 - lat1);
	const dLon = this.toRad(lon2 - lon1);
	const radLat1 = this.toRad(lat1);
	const radLat2 = this.toRad(lat2);

	const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
		Math.cos(radLat1) * Math.cos(radLat2) *
		Math.sin(dLon / 2) * Math.sin(dLon / 2);

	const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));

	const distance = R * c; // 计算距离（公里）
	return distance;

}